﻿using System;

class HexToDecimal
{
    static void Main()
    {
        //FormatExeption .. it is not a hex number
        Console.WriteLine("Please enter hex number");
        string hexNumber = Console.ReadLine();
        int sum = 0;
        for (int i = hexNumber.Length - 1; i >= 0; i--)
        {
            int num = 0;
            if (hexNumber[i] == 'A')
            {
                num = int.Parse("10");
            }
            else if (hexNumber[i] == 'B')
            {
                num = int.Parse("11");
            }
            else if (hexNumber[i] == 'C')
            {
                num = int.Parse("12");
            }
            else if (hexNumber[i] == 'D')
            {
                num = int.Parse("13");
            }
            else if (hexNumber[i] == 'E')
            {
                num = int.Parse("14");
            }
            else if (hexNumber[i] == 'F')
            {
                num = int.Parse("15");
            }
            else
            {
                num = int.Parse(hexNumber[i].ToString());
            }       
            sum += num * (int)(Math.Pow(16, ((hexNumber.Length - 1) - i)));
        }

        Console.WriteLine("The decimal number is: {0}", sum); 
    }
}
